import clc from 'cli-color'
export class Logger {
  private static lastLogTime = Date.now() // 时间戳
  /**
   * 打印日志
   * @param message 日志消息
   * @param context 上下文
   */
  static log(message: string, context: string ) {
    const timestamp = new Date().toLocaleString() // 获取当前时间戳
    const pid = process.pid // 获取当前进程 ID
    const currentTime = Date.now() 
    const timeDiff = currentTime - this.lastLogTime
    console.log(`${clc.green('[Nest]')} ${pid}  - ${timestamp} ${clc.green('LOG')} ${clc.yellow([context])} ${clc.green(message)} ${clc.yellow('+' + timeDiff + 'ms')}`)
    this.lastLogTime = currentTime // 保存当前时间戳 为下次 log 函数日志打印调用准备
  }
}
